package com.cmcc.groupcontacts.common;

import java.io.IOException;

import android.util.Log;

public class CommService {

	public static final String FILE_PASSWORD = "FILE_PASSWORD";

	public static CommService getInstance() {
		return new CommService();
	}

	/**
	 * 备份数据到服务器，
	 * 
	 * @param content
	 *            需要备份的文件内容
	 * @param filename
	 *            文件名称
	 * @return true：备份成功
	 * @throws IOException
	 * @throws NoSuchAlgorithmException
	 */
	public boolean backup(byte[] content, String filename) {
		return true;
	}

	public boolean backupTest(String content, String filename) {
//		Log.d("xml", content);
		return true;
	}

	/**
	 * 获取指定的备份文件内容
	 * 
	 * @param filename
	 *            备份的文件名 ，如果指定的文件不存在，返回异常
	 * @return 文件内容
	 * @throws IOException
	 * @throws NoSuchAlgorithmException
	 */
	public byte[] getBackupFile(String filename) {
		return null;
	}

	public String getBackupFileXmlTest(String filename) {
//		String xml = "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?> "+
//	"<notepad>"+
//		"<categories>"+
//			"<category id='1' createTime='1379837669244' lastUpdateTime='1379837669244' version='1' noteCount='2'>默认分类</category>" +
//			"<category id='2' createTime='1379837669244' lastUpdateTime='1379837669244' version='1' noteCount='1'>新分类</category>" +
//		"</categories>"+
//		"<notes>"+
//			"<note id='1' createTime='1379837669244' lastUpdateTime='1379837669244' version='1' categoryId='1' title='111'></note>" +
//			"<note id='2' createTime='1379837669244' lastUpdateTime='1379837669244' version='1' categoryId='1' title='222'></note>" +
//			"<note id='3' createTime='1379837669244' lastUpdateTime='1379837669244' version='1' categoryId='2' title='333'></note>" +
//		"</notes>"+
//	"</notepad>";
		String xml = "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><notepad><categories><category id='1' createTime='1379838244011' lastUpdateTime='1379838244012' version='0' noteCount='0'>默认分类</category><category id='2' createTime='1379853904790' lastUpdateTime='1379853904790' version='0' noteCount='0'>啊啊啊</category></categories><notes><note id='2' categoryId='2' createTime='1379853922634' lastUpdateTime='1379853922634' version='0' title='null'>3435</note><note id='1' categoryId='1' createTime='1379853871522' lastUpdateTime='1379853871522' version='0' title='null'>123</note></notes></notepad>";
				
		return xml;
	}

	/**
	 * 返回指定类型的文件列表
	 * 
	 * @param fileExt
	 *            文件后缀名
	 * @return 文件列表，如果有多个文件，用":"（冒号）分开。null，没有要找的文件
	 * @throws IOException
	 */
	public String[] getBackupFilenameList(String fileExt) throws IOException {
		return null;
	}

}
